<template>

    <div>
        <ul>
            <li v-for="m in msgList" :key="m.id">
                <router-link :to="{
                    name: 'detail',
                    query: {
                        id: m.id,
                        title: m.title
                    }
                }">
                    {{ m.title }}
                </router-link>
                <button @click="pushShow(m)">push查看</button>
                <button @click="replaceShow(m)">replace查看</button>
            </li>
        </ul>
        <div>
            <router-view></router-view>
        </div>
    </div>

</template>

<script>
export default {
    name: 'Msg',
    data() {
        return {
            msgList: [
                { id: '001', title: '消息1111' },
                { id: '002', title: '消息2222' },
                { id: '003', title: '消息3333' },
            ]
        }
    },
    methods: {
        pushShow(m) {
            this.$router.push({
                name: 'detail',
                    query: {
                        id: m.id,
                        title: m.title
                    }
            })
        },
        replaceShow(m) {
            this.$router.replace({
                name: 'detail',
                    query: {
                        id: m.id,
                        title: m.title
                    }
            })
        },
    },

}
</script>

<style scoped>
li {
    list-style: none;
}
</style>